package com.hcq.service;

import com.common.entity.GlobalMsg;
import com.common.entity.Rsp;
import com.hcq.mapper.GlobalMsgMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GlobalMsgServiceImpl {

    @Autowired
    private GlobalMsgMapper globalMsgMapper;

    public Rsp findByUserId (GlobalMsg globalMsg){
        List<GlobalMsg> globalMsgs = globalMsgMapper.findByUserId(globalMsg);
        return globalMsgs != null ? Rsp.success(globalMsgs): Rsp.fail().msg("查询失败");
    }

    public Rsp updateStatus (GlobalMsg globalMsg){
        Integer result = globalMsgMapper.updateStatus(globalMsg);
        return result == 1 ? Rsp.success(result): Rsp.fail().msg("修改失败");
    }

    public Rsp addOne(GlobalMsg globalMsg){
        Integer result = globalMsgMapper.addOne(globalMsg);
        return result == 1 ? Rsp.success(result): Rsp.fail().msg("添加失败");
    }
}
